package com.bocom.dao;

import java.sql.Timestamp;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import com.bocom.entity.AjfxEntity;

//@Repository
public class AjfxDao {

	// @Autowired
	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	@SuppressWarnings("unchecked")
	public List<AjfxEntity> findAll() {

		String hsql = "from ajfx";
		Query query = sessionFactory.getCurrentSession().createQuery(hsql);
		List<AjfxEntity> ulist = query.list();
		if (ulist.size() > 0) {
		}
		return ulist;
	}	
	
	@SuppressWarnings("unchecked")
	public List<AjfxEntity> select_jobsubmit(String kssj, String jssj) {
		
		java.sql.Timestamp sql_kssj = null;
		java.sql.Timestamp sql_jssj = null;
		try{	
			
			kssj = ""+kssj+" 00:00:00";
			jssj = ""+jssj+" 00:00:00";			
	    	sql_kssj=Timestamp.valueOf(kssj);
	    	sql_jssj=Timestamp.valueOf(jssj); 	
//	    	System.out.println("sql_kssj "+sql_kssj);
//	    	System.out.println("sql_jssj "+sql_jssj);
	    	
	    	}catch(Exception e){
	    	e.printStackTrace();
	    	}
		
		String hsql = "from ajfx where jobsubmit>=:kssj and jobsubmit<=:jssj";
		Query query = sessionFactory.getCurrentSession().createQuery(hsql);
		query.setTimestamp("kssj", sql_kssj);
		query.setTimestamp("jssj", sql_jssj);
		
//		System.out.println("AjfxDao hsql=" + hsql);	
		List<AjfxEntity> ulist = query.list();
		if (ulist.size() > 0) {
			System.out.println("Result rows ="+ulist.size());
		}

		return ulist;
	
	}
}
